package impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;

import model.*;
import dao.*;

public class VentaDAOImpl implements VentaDAO {


	private HibernateTemplate hibernateTemplate = null;
	@Override
	public List<Venta> getAll() {
		return this.hibernateTemplate.loadAll(Venta.class);
	}

	@Override
	public Venta getById(Integer facturaID) {
		return this.hibernateTemplate.get(Venta.class, facturaID);
	}

	@Override
	public void update(Venta venta) {
		this.hibernateTemplate.update(venta);
	}

	@Override
	public void delete(Integer facturaID) {
		this.hibernateTemplate.delete(facturaID);
	}

	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory){
		this.hibernateTemplate = new HibernateTemplate(sessionFactory);
	}

	@Override
	public void save(Venta venta) {
		this.hibernateTemplate.save(venta);
		
	}
}
